﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LDTB.LDTBDataSetTableAdapters;
using LDTB.Service;
using Microsoft.Reporting.WinForms;

namespace LDTB
{
    public partial class ReportCenter : Form
    {


        public ReportCenter()
        {
            InitializeComponent();
        }

        public ReportCenter(int _catid, int _wardid)
        {
            InitializeComponent();
           
        }
        

        private void ReportCenter_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'LDTBDataSet.OptionCate' table. You can move, or remove it, as needed.

            
            // TODO: This line of code loads data into the 'LDTBDataSet.People' table. You can move, or remove it, as needed.

            //ReportParameter p = new  ReportParameter("CateObject","Đối tượng chính sách"),p2=new ReportParameter("WardName","Tiên nữ");
            //this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] {p,p2});

            //this.PeopleTableAdapter.Connection.ConnectionString = DataService.StrCnn;
            //this.PeopleTableAdapter.FillCom(this.LDTBDataSet.People,catid,wardid);
            
            // TODO: This line of code loads data into the 'LDTBDataSet.People' table. You can move, or remove it, as needed.
            //this.PeopleTableAdapter.Connection.ConnectionString = "";



            //OptionCateTableAdapter ca = new OptionCateTableAdapter();
            //ca.ClearBeforeFill = true;
            //ca.Fill(this.LDTBDataSet.OptionCate);
            //Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();
            //reportDataSource1.Name = "LDTBDataSet_OptionCate";
            //reportDataSource1.Value = LDTBDataSet.OptionCate;
            //PeopleTableAdapter.FillCom(this.LDTBDataSet.People);


            //this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);

            //this.reportViewer1.RefreshReport();
        }

        public void ShowSimple(int catid,int wardid) {

            ReportParameter p = new ReportParameter("CateObject", "Đối tượng chính sách"), p2 = new ReportParameter("WardName", "Tiên nữ");
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p, p2 });

            this.PeopleTableAdapter.Connection.ConnectionString = DataService.StrCnn;
            this.PeopleTableAdapter.FillCom(this.LDTBDataSet.People, catid, wardid);
            this.reportViewer1.RefreshReport();

        
        }

        public void ShowMultiple(int villageid,int wardid, int usid,string firstname,string familyname,int catid, int groupid,int numberpair ) {

            string _firstname = firstname == "" ? "%" : firstname + "%";
            string _familyname = familyname == "" ? "%" : familyname + "%";

            ReportParameter p = new ReportParameter("CateObject", "Đối tượng chính sách"), p2 = new ReportParameter("WardName", "Tiên nữ");
            this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { p, p2 });

            this.PeopleTableAdapter.Connection.ConnectionString = DataService.StrCnn;
            this.PeopleTableAdapter.FillBy(this.LDTBDataSet.People, villageid, wardid, usid, _firstname, _familyname, catid, groupid, (byte)numberpair);

            this.reportViewer1.RefreshReport();
        
        }

    }
}
